{{left_sidebar_enabled,right_sidebar_enabled=False,False}}
{{extend 'layout.html'}}
{{from ndsfunctions import truncquest}}
<h1>My Answers</h1>
{{=form}}

{{if quests:}}
<table id='TabAnswers' class='issuetable'>
				<thead>
					<tr>
						<th width="5%">Level</th>
                        <th width="50%">Question</th>
                        <th width="8%">Status</th>
                        <th width="15%">My Answer</th>
                        <th width="16%">Correct Ans</th>
                        <th width="6%">Score</th>                     
                    </tr>
                </thead>
                    <tbody>
{{for i,row in enumerate(quests):}}
{{if i==items_per_page: break}}
{{rowans=0}}
<tr class={{if row.questionid.status == 'In Progress':}}"inprog"{{elif row.answer == row.questionid.correctans:}}"correct"((rowans=1}}{{else:}}"wrong"((rowans=2}}{{pass}}>
<th><a href="{{=URL('viewquest','index',args=[row.questionid.id])}}">{{=row.questionid.level}}</a></th>
<td>{{=truncquest(row.questionid.questiontext)}}</td>
<td>{{if row.status == 'In Progress':}}In Progress{{else:}}{{=row.questionid.status}} {{pass}}</td>
<td>{{=row.questionid.answers[row.answer-1]}}</td>
<td>{{if row.status == 'In Progress':}}-{{else:}}{{=row.questionid.correctanstext}} {{pass}}</td>
<td>{{=row.score}}</td>
</tr>
{{pass}}
 </tbody>
</table>
                        
{{if page:}}
<a href="{{=URL(args=[page-1,q,s])}}">previous</a>
{{pass}}

{{if len(quests)>items_per_page:}}
<a href="{{=URL(args=[page+1,q,s])}}">next</a>
{{pass}}

{{else:}}
<p>No questions for selected filters.</p>
{{pass}}

<script>
function showcountryValue(newValue)
{
	document.getElementById("viewscope_country").value=newValue;
    jQuery('#subdivopt').empty();
    ajax('{{=URL('submit','subdivn')}}', ['country'], 'subdivopt');
    document.getElementById("viewscope_subdivision").value="Unspecified";
}

function showsubdivValue(newValue)
{
	document.getElementById("viewscope_subdivision").value=newValue;
}


jQuery(document).ready(function(){
     jQuery('#viewscope_country__row .w2p_fc').html('<select id="countryopt" name="countryopt" onchange="showcountryValue(this.value)"> <option value="{{=form.vars.country}}">{{=form.vars.country}}</option>   </select>');
   jQuery('#viewscope_subdivision__row .w2p_fc').html('<select id="subdivopt" name="subdivopt" onchange="showsubdivValue(this.value)"> <option value="{{=form.vars.subdivision}}">{{=form.vars.subdivision}}</option> </select>');

    jQuery('#viewscope_continent__row').hide();    
    jQuery('#viewscope_country__row .w2p_fw').hide();    
    jQuery('#viewscope_subdivision__row .w2p_fw').hide(); 

    if(jQuery("[id='scope1 Global']").prop('checked'))
            {jQuery('#viewscope_continent__row').hide()
            jQuery('#viewscope_country__row').hide()
            jQuery('#viewscope_subdivision__row').hide()};
    if(jQuery("[id='scope2 Continental']").prop('checked'))
            {jQuery('#viewscope_continent__row').show()
            jQuery('#viewscope_country__row').hide()
            jQuery('#viewscope_subdivision__row').hide()};
    if(jQuery("[id='scope3 National']").prop('checked'))
            {jQuery('#viewscope_continent__row').show();
            jQuery('#viewscope_country__row').show();
            jQuery('#viewscope_country__row .w2p_fw').hide();
            jQuery('#viewscope_subdivision__row').hide()};
     if(jQuery("[id='scope4 Local']").prop('checked'))
            {jQuery('#viewscope_continent__row').show()
            jQuery('#viewscope_country__row').show();
            jQuery('#viewscope_country__row .w2p_fw').hide();
            jQuery('#viewscope_subdivision__row').show();
            jQuery('#viewscope_subdivision__row .w2p_fw').hide()};


    if (jQuery('#viewscope_showscope').prop('checked')==false){
       jQuery('#viewscope_scope__row').hide();
       jQuery('#viewscope_continent__row').hide();
       jQuery('#viewscope_country__row').hide();
       jQuery('#viewscope_subdivision__row').hide();};
    if (jQuery('#viewscope_showcat').prop('checked')==false){
        jQuery('#viewscope_category__row').hide();};


   jQuery('#viewscope_showcat').change(function(){
              jQuery('#viewscope_category__row').toggle()});

   jQuery('#viewscope_showscope').change(function(){
            if(jQuery('#viewscope_showscope').prop('checked')==false) {
                jQuery('#viewscope_scope__row').hide();
                jQuery('#viewscope_continent__row').hide();
                jQuery('#viewscope_country__row').hide();
                jQuery('#viewscope_subdivision__row').hide();}
            else
                {jQuery('#viewscope_scope__row').show();
            if(jQuery("[id='scope3 National']").prop('checked'))
            {jQuery('#viewscope_continent__row').show()
            jQuery('#viewscope_country__row').show()
            jQuery('#viewscope_subdivision__row').hide()};
            if(jQuery("[id='scope1 Global']").prop('checked'))
            {jQuery('#viewscope_continent__row').hide()
            jQuery('#viewscope_country__row').hide()
            jQuery('#viewscope_subdivision__row').hide()};
            if(jQuery("[id='scope2 Continental']").prop('checked'))
            {jQuery('#viewscope_continent__row').show()
            jQuery('#viewscope_country__row').hide()
            jQuery('#viewscope_subdivision__row').hide()};
            if(jQuery("[id='scope4 Local']").prop('checked'))
            {jQuery('#viewscope_continent__row').show()
            jQuery('#viewscope_country__row').show()
            jQuery('#viewscope_subdivision__row').show()};}

            });

   jQuery('input[name=scope]').change(function(){
            if(jQuery("[id='scope1 Global']").prop('checked'))
            {jQuery('#viewscope_continent__row').hide()
            jQuery('#viewscope_country__row').hide()
            jQuery('#viewscope_subdivision__row').hide()};
            if(jQuery("[id='scope2 Continental']").prop('checked'))
            {jQuery('#viewscope_continent__row').show()
            jQuery('#viewscope_country__row').hide()
            jQuery('#viewscope_subdivision__row').hide()};
            if(jQuery("[id='scope3 National']").prop('checked'))
            {jQuery('#viewscope_continent__row').show()
            jQuery('#viewscope_country__row').show()
            jQuery('#viewscope_country__row .w2p_fw').hide();
            jQuery('#viewscope_subdivision__row').hide()};
            if(jQuery("[id='scope4 Local']").prop('checked'))
            {jQuery('#viewscope_continent__row').show()
            jQuery('#viewscope_country__row').show()
            jQuery('#viewscope_country__row .w2p_fw').hide();
            jQuery('#viewscope_subdivision__row').show()
            jQuery('#viewscope_subdivision__row .w2p_fw').hide()};
            });

            jQuery('#viewscope_continent ').change(function(){            
            jQuery('#countryopt').empty();
            ajax('{{=URL('submit','country')}}', ['continent'], 'countryopt');});

            jQuery('#viewscope_country').change(function(){
            jQuery('#subdivopt').empty();
            ajax('{{=URL('submit','subdivn')}}', ['country'], 'subdivopt');});



});


</script>

